﻿using System;

namespace ParsePtb.attr

{
    //导入的注解【特征值/注解】
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
    public class ColumnInfoAttr : Attribute
    {
        //位置
        int index = -1;

        // 长度
        int length = 32;

        // 是否为空
        bool nullable = false;

        // 时间格式
        string dateFormat = "";

        //正则表单式 验证数据格式
        string pattern = "";

        public string ColumnName { set; get; }

        public ColumnInfoAttr(int index, int length)
        {
            this.index = index;
            this.length = length;
        }

        public ColumnInfoAttr(int index, int length, bool nullable)
        {
            this.index = index;
            this.length = length;
            this.nullable = nullable;
        }

        public ColumnInfoAttr(int index, int length, bool nullable, string dateFormat)
        {
            this.index = index;
            this.length = length;
            this.nullable = nullable;
            this.dateFormat = dateFormat;
        }

        public ColumnInfoAttr(int index, int length, bool nullable, string dateFormat, string pattern)
        {
            this.index = index;
            this.length = length;
            this.nullable = nullable;
            this.dateFormat = dateFormat;
            this.Pattern = pattern;
        }

        public int Index { get => index; set => index = value; }
        public int Length { get => length; set => length = value; }
        public bool Nullable { get => nullable; set => nullable = value; }
        public string DateFormat { get => dateFormat; set => dateFormat = value; }
        public string Pattern { get => pattern; set => pattern = value; }
    }
}
